export function getCookie(name:string){
  const reg=new RegExp(`(^| )${name}=([^;]*)(;|$)`)
  const arr=document.cookie.match(reg);
  if(arr){
    return arr[2];
  }else{
    return null;
  }
}

export function setCookie(name:string,value:string,time=7258089600000,path='/',domain=document.location.hostname){
  const exp=(new Date(time)).toString();
  document.cookie=`${name}=${value};expires=${exp};path=${path};domain=${domain}`;
}

export function delCookie(name:string){
  const exp=(new Date(1997,1,1)).toString();
  document.cookie=`${name}=;expires=${exp};`;
}

export function getCookies(){
  const result:any={};
  const arr=document.cookie.split('; ');
  for(let s of arr){
    const arr1=s.split('=');
    result[arr1[0]]=arr1[1];
  }
  return result;
}